@extends('admins.layouts.default')
@section('content')
	@if (allowed('group/create'))
	<p>
	    <a href="{{ url('admin/group/create') }}" class="btn btn-primary btn-xs">
	        <span class="glyphicon glyphicon-pencil"></span> Add new group            
	    </a>
    </p>
    @endif
    
    @if ($groups->count())
    	<div class="table-responsive">
			<table class="table table-striped table-bordered table-condensed table-hover">
		        <thead>
					<tr>
	                	<th>name</th>
	            		<th>&nbsp;</th>
		            </tr>
		        </thead>
		        <tbody>
		            @foreach ($groups as $group)
		                <tr>
		                    <td>{{ $group->name }}</td>
		                    @if (allowed('group/edit'))
		                    <td>
		                       <a class="btn btn-info btn-xs" href="{{ url("admin/group/$group->id/edit") }}"><span class="glyphicon glyphicon-edit"></span> Edit</a>
		                    </td>
		                    @endif
		                    @if (allowed('group/destroy'))
		                   	<td class="text-center">
		          				{{ Form::open(['method' => 'DELETE', 'route' => ['admin.group.destroy', $group->id]]) }}
		                            <button type="submit" class="btn btn-danger btn-xs" data-confirm="Are you sure you want to delete this group?"><span class="glyphicon glyphicon-remove"></span> Del</button>
		                        {{ Form::close() }}
		                    </td>
		                    @endif
		                </tr>
		            @endforeach
	            </tbody>
	        </table>
		</div>
		<div class="pagination">{{ $groups->links() }}</div>
    @else
        <p>There are no groups.</p>
    @endif
    
    <script>
	    $(function() {
			$(".confirm").on("click", function() {
				return confirm($(this).data("confirm"));
			});
	    });
    </script>
@stop